﻿<%@ Page Language="C#" AutoEventWireup="true" ValidateRequest="false" %>
<script runat="server">
	string html;	
	protected override void OnLoad(EventArgs e)
	{
		System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
		int count = 10000;
		jsonar.Obj json = null;
		string str = null;

		html = "生成" + count + "次：";
		watch.Restart();
		for (int i = 0; i < count; i++)
		{
			json = new jsonar.Obj();
			json.Add("Headers", this.Request.Headers, 5);
			json.Add("Params", this.Request.Params, 5);
		}
		watch.Stop();
		html += watch.ElapsedTicks.ToString() + "时钟/" + watch.ElapsedMilliseconds.ToString() + "毫秒";

		html += "<br/>输出" + count + "次：";
		watch.Restart();
		for (int i = 0; i < count; i++)
		{
			str = json.ToString();
		}
		watch.Stop();
		html += watch.ElapsedTicks.ToString() + "时钟/" + watch.ElapsedMilliseconds.ToString() + "毫秒";

		html += "<br/>解析" + count + "次：";
		watch.Restart();
		for (int i = 0; i < count; i++)
		{
			jsonar.Json js = jsonar.Json.Parse(str);
		}
		watch.Stop();
		html += watch.ElapsedTicks.ToString() + "时钟/" + watch.ElapsedMilliseconds.ToString() + "毫秒";
	}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Json性能测试</title>
</head>
<body>
<div class="Div">
<%=this.html%>
</div>
</body>
</html>
